<?php
namespace app\admin\controller\finance;
use app\admin\controller\Controller;
use app\common\library\wechat\Abonus;
use app\common\model\divide\System as SystemModel;
use think\Db;
/**
 * 客户流转日志
 */
class System extends Controller{
    /**
     * @return string
     */
    public function index(){
        $fromType=input('get.fromType');
        $where['id']=['>',0];
        if($fromType){
            $where['fromType']=['=',$fromType];
        }
        $datatype=input('get.datatype');
        if($datatype){
            $where['datatype']=['=',$datatype];
        }
        $search=input('get.search');
        if($search){
            //获取客户ids
            $ids=Db::name('love_customer')->where(['name|phone'=>['like','%'.$search.'%']])->field('id,name,phone')->select()->toArray();
            if($ids){
                foreach ($ids as $k=>$v){
                    $is[]=$v['id'];
                }
                $where['customerid']=['in',$is];
            }
        }
        $list=Db::name('love_log')->where($where)->order('create_time desc')->paginate(15, false, [
            'query' => \request()->request()
        ]);
        return $this->fetch('index', compact('list'));
    }

}